//
//  RNSKBez.m
//  Breezy
//
//  Created by Kai Cherry on 8/12/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "RNSKBez.h"


@implementation  NSBezierPath (RNSKBez)

+ (void)drawRect:(NSRect)rect withGradientFrom:(NSColor*)colorStart to:(NSColor*)colorEnd
{
    float fraction = 0;
    float height = rect.size.height - 1;
    float width = rect.size.width;
    float step = 1/height;
    int i;
    
    NSRect gradientRect = NSMakeRect(rect.origin.x, rect.origin.y, width, 1.0);
    [colorEnd set];
    [NSBezierPath fillRect:gradientRect];
    
    for(i = 0; i < height; i++)
    {
        gradientRect.origin.y++;
        NSColor * gradientColor = [colorStart blendedColorWithFraction:fraction ofColor:colorEnd];
        [gradientColor set];
        [NSBezierPath fillRect:gradientRect];
        fraction += step;
    }
}

@end
